using BCW;
using BCW.Friends;
using UnityEngine;

public class FriendsInSelectModePanel : MonoBehaviour
{
	private const int COUNT_MAX_INVITE = 3;

	[SerializeField]
	private UILabel nameLable;

	[SerializeField]
	private UIBasicSprite skin;

	[SerializeField]
	private GameObject checkBoxGameObject;

	[SerializeField]
	private GameObject checkMarkGameObject;

	private string _idPlayer;

	private bool _isActiveCheckMark;

	public string IdPlayer
	{
		get
		{
			return _idPlayer;
		}
		set
		{
			_idPlayer = value;
		}
	}

	public void SetName(string name)
	{
		nameLable.text = name;
	}

	public void SetSkin(string skinId)
	{
		if (!skin.mainTexture.name.Equals("render_" + skinId))
		{
			skin = skin.ReplaceForCurrentPlatform();
			skin.LoadTextureAndAlphaMask("AtlasShopGuns/", "render_" + skinId);
		}
	}

	public void RefreshMark()
	{
		_isActiveCheckMark = FriendsController.instance.IdsFrinedsInviteToBattle.Contains(IdPlayer);
		checkMarkGameObject.SetActive(_isActiveCheckMark);
	}

	private void OnClick()
	{
		if ((bool)FriendsController.instance)
		{
			if (FriendsController.instance.IdsFrinedsInviteToBattle.Contains(IdPlayer))
			{
				FriendsController.instance.IdsFrinedsInviteToBattle.Remove(IdPlayer);
			}
			else if (FriendsController.instance.IdsFrinedsInviteToBattle.Count < 3)
			{
				FriendsController.instance.IdsFrinedsInviteToBattle.Add(IdPlayer);
			}
			RefreshMark();
		}
	}
}
